home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_strifle_m.cog < prev    next >
Text File  |  1998-02-25  |  6KB  |  215 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # WEAP_STRIFLE.COG
  4. #
  5. # WEAPON 3 script - Stormtrooper Rifle
  6. #
  7. # The standard rifle used by the stormtroopers.  Not as accurate as the Bryar Pistol.
  8. # This weapon has only one type of fire.
  9. #
  10. # - Affected by MagSealed sectors/surfaces.
  11. #
  12. # [YB & CYW]
  13. #
  14. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  15.  
  16.  
  17. symbols
  18.  
  19. model       povModel=strv.3do                   local
  20. model       povModel_m=strv_m.3do               local
  21. model       weaponMesh=strg.3do                 local
  22.  
  23. keyframe    mountAnim=StrVmnt.key               local
  24. keyframe    dismountAnim=StrVdis.key            local
  25. keyframe    povfireAnim=StrVpst1.key            local
  26. keyframe    holsterAnim=kyhlstr.key             local
  27.  
  28. sound       mountSound=df_rif_ready.wav         local
  29. sound       dismountSound=PutWeaponAway01.wav   local
  30. sound       fireSound=trprsht2.wav              local
  31. sound       outSound=trprout.wav                local
  32. sound            failSound=weapfail.wav                    local
  33.  
  34. template    projectile=+stlaser                 local
  35. template    projectileB=+swsparks                 local
  36.  
  37. thing       player                              local
  38.  
  39. vector      randVec                             local
  40.  
  41. flex        fireWait=0.2                        local
  42. flex        holsterWait                         local
  43. flex        powerBoost                          local
  44. flex        autoAimFOV=25                       local
  45. flex        autoAimMaxDist=5                    local
  46.  
  47. int         dummy                               local
  48. int         trackID=-1                          local
  49. int         fireChannel=-1                      local
  50. int         holsterTrack                        local
  51. int         mode                                local
  52.  
  53. message     activated
  54. message     deactivated
  55. message     selected
  56. message     deselected
  57. message     autoselect
  58. message     fire
  59. message     timer
  60.  
  61. end
  62.  
  63. # ========================================================================================
  64.  
  65. code
  66.  
  67. fire:
  68.    player = GetSourceRef();
  69.    mode = GetSenderRef();
  70.  
  71.    // Check that the player is still alive.
  72.    if(GetThingHealth(player) <= 0)
  73.    {
  74.       Return;
  75.    }
  76.  
  77.    // Check Ammo - If we are out, autoselect best weapon.
  78.    // It should always use two energy cells, but -- as in DF --
  79.    // allow the last fire if there is only one left...
  80.    if(GetInv(player, 11) < 1.0)
  81.    {
  82.       PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
  83.       if((GetAutoSwitch() & 1))
  84.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  85.       Return;
  86.    }
  87.  
  88.    // Get random aiming error
  89.    randVec = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);
  90.  
  91.     SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  92.  
  93.    SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0);
  94.     if (GetInv(player, 93) > 0.0)
  95.         dummy = FireProjectile(player, projectileB, failSound, 8, '0.0168 0.1896 0.00', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2);
  96.     else
  97.         dummy = FireProjectile(player, projectile, fireSound, 8, '0.0168 0.1896 0.00', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2);
  98.    // SetThingVel(dummy, vectorScale(GetThingVel(dummy), 0.01));
  99.  
  100.    ChangeInv( player, 11, -2.0 );
  101.    jkPlayPOVKey( player, povfireAnim, 1, 0x38 );
  102.  
  103.    powerBoost = GetInv(player, 63);
  104.    ChangeFireRate(player, fireWait/powerBoost);
  105.  
  106.    Return;
  107.  
  108. # ........................................................................................
  109.  
  110. activated:
  111.    player = GetSourceRef();
  112.    mode = GetSenderRef();
  113.  
  114.     if (GetInv(player, 93) > 0.0)
  115.         SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  116.  
  117.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  118.    powerBoost = GetInv(player, 63);
  119.    ActivateWeapon(player, fireWait/powerBoost, mode);
  120.    Return;
  121.  
  122. # ........................................................................................
  123.  
  124. deactivated:
  125.    player = GetSourceRef();
  126.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  127.    DeactivateWeapon(player, mode);
  128.    Return;
  129.  
  130. # ........................................................................................
  131.  
  132. selected:
  133.    player = GetSourceRef();
  134.  
  135.    PlayMode(player, 41);
  136.    PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
  137.     if (GetInv(player, 67) == 0.0)
  138.         jkSetPOVModel(player, povModel);        // Kyle hand
  139.     else
  140.         jkSetPOVModel(player, povModel_m);    // Mara Hand
  141.    SetArmedMode(player, 1);
  142.    jkSetWeaponMesh(player, weaponMesh);
  143.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  144.    trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
  145.    SetMountWait(player, GetKeyLen(mountAnim));
  146.    jkClearFlags(player, 0x5);
  147.    SetCurWeapon(player, GetWeaponBin(3));
  148.  
  149.    SetTimerEx(1.0, 10, 0.0, 0.0);
  150.  
  151.    Return;
  152.  
  153. # ........................................................................................
  154.  
  155. deselected:
  156.    player = GetSourceRef();
  157.  
  158.    PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
  159.    jkPlayPOVKey(player, dismountAnim, 0, 18);
  160.    holsterWait = GetKeyLen(holsterAnim);
  161.    SetMountWait(player, holsterWait);
  162.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  163.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  164.    if (trackID != -1)
  165.    {
  166.       jkStopPOVKey(player, trackID, 0);
  167.       trackID = -1;
  168.    }
  169.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  170.  
  171.    Return;
  172.  
  173. # ........................................................................................
  174.  
  175. autoselect:
  176.    player = GetSourceRef();
  177.  
  178.    // If the player has the weapon
  179.    if(GetInv(player, GetWeaponBin(3)) != 0.0)
  180.    {
  181.       // If the player has ammo or has the scope up.
  182.       if (
  183.             GetInv(player, 11) != 0.0 ||
  184.             GetCurWeapon(player) == 13
  185.             )
  186.       {
  187.          ReturnEx(600.0);
  188.       }
  189.       else
  190.       {
  191.          ReturnEx(-1.0);
  192.       }
  193.    }
  194.    else
  195.    {
  196.       ReturnEx(-1.0);
  197.    }
  198.  
  199.    Return;
  200.  
  201. # ........................................................................................
  202.  
  203. timer:
  204.     if (GetSenderID() == 2)
  205.         StopKey(player, holsterTrack, 0.0);
  206.     else
  207.     if (GetSenderID() == 10)
  208.         if (GetCurWeapon(player) == 3)
  209.             SetCameraZoom(0, 1.0, 500.0);
  210.  
  211.    Return;
  212.  
  213. end
  214.  
  215.